package com.gko100.dao.impl;

import java.util.List;

import com.gko100.dao.LanguageDao;
import com.gko100.dao.PermissionDao;
import com.gko100.dao.basehibernatesupport.BaseHibernateDaoSupport;
import com.gko100.model.Language;
import com.gko100.model.Permission;


public class LanguageDaoHibernate extends BaseHibernateDaoSupport implements LanguageDao {

	/* 
	 * {见接口方法说明}
	 */
	public void add_lang(Language lang) {
		
		this.getHibernateTemplate().save(lang);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public void del_lang(Language lang) {
		
		this.getHibernateTemplate().delete(lang);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public List<Language> findLangListAll() {
		
		List<Language> langList = this.getHibernateTemplate().find("from Language");
		if(langList!=null&&langList.size()>=1){
			return langList;
		}else{
			logger.debug(this.getClass().getMethods().toString()+"为空");
			return null;
		}
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public Language findLangyLangId(Integer langId) {
		Language lang = this.getHibernateTemplate().get(Language.class, langId);
		if(lang!=null){
			return lang;
		}else{
			logger.debug(this.getClass().getMethods().toString()+"为空");
			return null;
		}
	
	}
	
	public Language findLangByLangName(String langName){
		
		List<Language> langList = this.getHibernateTemplate().find("from Language as l where l.langName=?", langName);
		if(langList!=null&&langList.size()>=1){
			return langList.get(0);
		}else{
			logger.debug(this.getClass().getMethods().toString()+"为空");
			return null;
		}
		
		
	}
	
	/* 
	 * {见接口方法说明}
	 */
	public void modify_lang(Language lang) {
		
		this.getHibernateTemplate().update(lang);
		
	}

	
}
